package com.hghivln.erpwarehouse.system.mapper;

import com.hghivln.erpwarehouse.system.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author hghivln
 * @since 2021-06-21
 */
@Repository
public interface UserMapper extends BaseMapper<User> {

    @Select("select max(ordernum) from sys_user")
    Integer queryUserMaxOrderNum();

    @Select("select rid from sys_user_role where uid = #{uid}")
    List<Integer> queryRoleIdsByUid(Integer uid);

    @Delete("delete from sys_user_role where uid = #{uid}")
    void deletRoleUserById(Integer uid);

    @Insert("insert into sys_user_role(uid,rid) values(#{uid},#{rid})")
    void saveUserRole(@Param("uid") Integer uid,@Param("rid") Integer rid);
}
